<?php 
require_once("../includes/public.inc.php");
require_once ("../mobile/shop.php");
session_start();
$userinfo = isset($_SESSION['userinfo'])?$_SESSION['userinfo']:'';
$color = $_POST['color'];
$size = $_POST['size'];
$pro = getProductDetail($_POST['id']);
$credit = '';
if (!empty($userinfo)) {
	$credit = $userinfo['credit'];
// 	echo $credit;exit;
}
$price = ($pro['price']-$credit)>0?($pro['price']-$credit):'0.00';
$red = ($pro['price']-$credit)>0?$credit:$pro['price'];
// echo $price;exit;
?>

<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,user-scalable=no,maximum-scale=1,initial-scale=1">
<title>确认订单</title>
<link type="text/css" href="css/css.css" rel="stylesheet" />
<link type="text/css" href="css/pz-mobile.css" rel="stylesheet" />
<script type="text/javascript" src="../js/pz-mobile.js"></script>
<script type="text/javascript" src="../mobile/js/jQuery.js"></script>
<style>
.panel_ul{list-style:none; padding:0px}
.panel_ul *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;}
.show_li{padding:5px;width:50%;float:left;}
.list_li{padding:5px;width:100%;}
.list_li .trade-panel{position:relative;height:70px;background:#fff;border: 0px solid transparent;border-radius: 5px;-webkit-border-radius: 5px;-webkit-box-shadow: 0px 2px 3px rgba(0,0,0,0.3);box-shadow: 0px 0px 3px rgba(0,0,0,0.3);}
.list_li img{height:70px; width:80px; border:5px #fff solid;}
.list_li .trade-ds{padding:5px; top:0; left:80px; position:absolute;background:none;border-radius:0 0 5px 5px;-webkit-border-radius:0 0 5px 5px;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;}
.list_li .show_name{ font-size:13px;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;display:block;}
.list_li b{font-size:14px;color:#FF0000;padding-right:5px}
.list_li del{font-size:12px;color:#666;}
.list_li .point{font-size:12px;color:green;display:block;}

.show_li img{width:100%;border-radius:5px 5px 0 0;-webkit-border-radius:5px 5px 0 0}
.show_li .trade-panel{background:#fff;border: 0px solid transparent;border-radius: 5px;-webkit-border-radius: 5px;-webkit-box-shadow: 0px 2px 3px rgba(0,0,0,0.3);box-shadow: 0px 0px 3px rgba(0,0,0,0.3);}
.show_li .trade-ds{padding:5px; height:65px;background:#fff;border-radius:0 0 5px 5px;-webkit-border-radius:0 0 5px 5px;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;}
.show_li .show_name{ font-size:13px;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;display:block;}
.show_li b{font-size:14px;color:#FF0000;padding-right:5px}
.show_li del{font-size:12px;color:#666;}
.show_li .point{font-size:12px;color:green;display:block;}
.div-jg{width: 96%;height:50px;margin:5px 2%;border-bottom:1px solid #ecebf1;padding-top: 5px;font-size: 1rem}
.bottom_menu{
	bottom: 0;
	position: fixed;
	height:50px;
	width: 100%;
	z-index: 11109;
	background:#fff;
	border-top:1px solid #d9dadc;
}
.bottom_menu ul li{
	width:33.3%;
	height:50px;
	float:left;
	color:#fff;
	list-style-type:none;
}
.bottom_menu ul li a{
	font-size:0.6rem;
	text-decoration:none;
	color:#fff;
}
input{border:none;background:none;outline:none;font-size:1rem}
</style>
<script type="text/javascript"> 
$(function(){
	$(window).scroll(function() {
		if ($(window).scrollTop()>150){
			$(".bt-top").css("position", "fixed");
		}else{
			$(".bt-top").css("position", "relative");
		}
	});
	$(".tpbtn").click(function() {
		if ($(this).hasClass("on")){
			$("#J_Shade").removeClass("none");
			$(".circle").removeClass("hide").addClass("show");
			$(this).removeClass("on").addClass("off");
		}else{
			$("#J_Shade").addClass("none");
			$(".circle").removeClass("show").addClass("hide");
			$(this).removeClass("off").addClass("on");
		}
		
	});
});

var pro = ["北京","天津","上海","重庆","河北","山西","辽宁","吉林","黑龙江","江苏","浙江","安徽","福建","江西","山东","河南","湖北","湖南","广东","海南","四川","贵州","云南","陕西","甘肃","青海","内蒙古","广西","西藏","宁夏","新疆维吾尔自治区","香港","澳门","台湾"];

var city = {北京:["东城区","西城区","崇文区","宣武区","朝阳区","海淀区","丰台区","石景山区","房山区","通州区","顺义区","昌平区","大兴区","怀柔区","平谷区","门头沟区","密云县","延庆县"],天津:["和平区","河东区","河西区","南开区","河北区","红桥区","东丽区","西青区","北辰区","津南区","武清区","宝坻区","滨海新区","静海县","宁河县","蓟县"],上海:["黄浦区","卢湾区","徐汇区","长宁区","静安区","普陀区","闸北区","虹口区","杨浦区","闵行区","宝山区","嘉定区","浦东新区","金山区","松江区","青浦区","奉贤区","崇明县"],重庆:["渝中区","大渡口区","江北区","南岸区","北碚区","渝北区","巴南区","长寿区","双桥区","沙坪坝区","万盛区","万州区","涪陵区","黔江区","永川区","合川区","江津区","九龙坡区","南川区","綦江县","潼南县","荣昌县","璧山县","大足县","铜梁县","梁平县","开县","忠县","城口县","垫江县","武隆县","丰都县","奉节县","云阳县","巫溪县","巫山县","石柱土家族自治县","秀山土家族苗族自治县","酉阳土家族苗族自治县","彭水苗族土家族自治县"],河北:["石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水"],山西:["太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻州","临汾","吕梁"],辽宁:["沈阳","大连","鞍山","抚顺","本溪","丹东","锦州","营口","阜新","辽阳","盘锦","铁岭","朝阳","葫芦岛"],吉林:["长春","吉林","四平","辽源","通化","白山","松原","白城","延边朝鲜族自治州"],黑龙江:["哈尔滨","齐齐哈尔","鹤岗","双鸭山","鸡西","大庆","伊春","牡丹江","佳木斯","七台河","黑河","绥化","大兴安岭"],江苏:["南京","苏州","无锡","常州","镇江","南通","泰州","扬州","盐城","连云港","徐州","淮安","宿迁"],浙江:["杭州","宁波","温州","嘉兴","湖州","绍兴","金华","衢州","舟山","台州","丽水"],安徽:["合肥","芜湖","蚌埠","淮南","马鞍山","淮北","铜陵","安庆","黄山","滁州","阜阳","宿州","巢湖","六安","亳州","池州","宣城"],福建:["福州","厦门","莆田","三明","泉州","漳州","南平","龙岩","宁德"],江西:["南昌","景德镇","萍乡","九江","新余","鹰潭","赣州","吉安","宜春","抚州","上饶"],山东:["济南","青岛","淄博","枣庄","东营","烟台","潍坊","济宁","泰安","威海","日照","莱芜","临沂","德州","聊城","滨州","菏泽"],河南:["郑州","开封","洛阳","平顶山","安阳","鹤壁","新乡","焦作","濮阳","许昌","漯河","三门峡","南阳","商丘","信阳","周口","驻马店"],湖北:["武汉","黄石","十堰","荆州","宜昌","襄樊","鄂州","荆门","孝感","黄冈","咸宁","随州","恩施"],湖南:["长沙","株洲","湘潭","衡阳","邵阳","岳阳","常德","张家界","益阳","郴州","永州","怀化","娄底","湘西"],广东:["广州","深圳","珠海","汕头","韶关","佛山","江门","湛江","茂名","肇庆","惠州","梅州","汕尾","河源","阳江","清远","东莞","中山","潮州","揭阳","云浮"],海南:["海口","三亚"],四川:["成都","自贡","攀枝花","泸州","德阳","绵阳","广元","遂宁","内江","乐山","南充","眉山","宜宾","广安","达州","雅安","巴中","资阳","阿坝","甘孜","凉山"],贵州:["贵阳","六盘水","遵义","安顺","铜仁","毕节","黔西南","黔东南","黔南"],云南:["昆明","曲靖","玉溪","保山","昭通","丽江","普洱","临沧","德宏","怒江","迪庆","大理","楚雄","红河","文山","西双版纳"],陕西:["西安","铜川","宝鸡","咸阳","渭南","延安","汉中","榆林","安康","商洛"],甘肃:["兰州","嘉峪关","金昌","白银","天水","武威","酒泉","张掖","庆阳","平凉","定西","陇南","临夏","甘南"],青海:["西宁","海东","海北","海南","黄南","果洛","玉树","海西"],内蒙古:["呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔","巴彦淖尔","乌兰察布","锡林郭勒盟","兴安盟","阿拉善盟"],广西:["南宁","柳州","桂林","梧州","北海","防城港","钦州","贵港","玉林","百色","贺州","河池","来宾","崇左"],西藏:["拉萨","那曲","昌都","林芝","山南","日喀则","阿里"],宁夏:["银川","石嘴山","吴忠","固原","中卫"],新疆维吾尔自治区:["乌鲁木齐","克拉玛依","吐鲁番","哈密","和田","阿克苏","喀什","克孜勒苏","巴音郭楞","昌吉","博尔塔拉","伊犁","塔城","阿勒泰"],香港:["香港岛","九龙东","九龙西","新界东","新界西"],澳门:["澳门半岛","离岛"],台湾:["台北","高雄","基隆","新竹","台中","嘉义","台南市"]};
$(document).ready(function(){
for(var i=0;i<pro.length;i++){
$option=$("<option/>")
$option.attr("value",pro[i]);
$option.text(pro[i]);
$("#province").append($option);
}
$("#province").click(function(){
var cities=city[$(this).val()];
$(this).parent().find("#city").empty();
for(var i=0;i<cities.length;i++){
$option=$("<option/>")
$option.attr("value",cities[i]);
$option.text(cities[i]);
$(this).parent().find("#city").append($option);
}
});
});
</script>

<script type="text/javascript">
    $(function () {
        $("#number").change(function(){
            if ($(this).val() <= 0)
            {
            	$(this).val("1");
            	$("#totalmoney").val("<?=$price?>");
            	$("#red").val("<?=$red?>")
            }else
            {
            	var money = parseFloat($(this).val())*parseFloat($("#price").val())-<?=$credit?>;
            	if (money < 0)
            	{
            		money = 0.00
            	}
            	var red = parseFloat($(this).val())*parseFloat($("#price").val())-<?=$credit?>;
            	if (red >= 0)
            	{
                	red = <?=$credit?>
            	}
            	else
            	{
					red = parseFloat($(this).val())*parseFloat($("#price").val())
            	}
//     			alert(money);
    			$("#totalmoney").val(money);
    			$("#red").val(red)
            }
			
        });
        $("#submit").click(function(){
			if ($("#number").val() <= 0)
			{
				alert("商品购买数量错误！");return false;
			}
			if ($("#name").val() == "")
			{
				alert("请输入收货姓名");return false;
			}
			if ($("#phone").val() == "")
			{
				alert("请输入联系电话");return false;
			}
			if ($("#province").val() == "")
			{
				alert("请选择省份");return false;
			}
			if ($("#city").val() == "")
			{
				alert("请选择城市");return false;
			}
			if ($("#address").val() == "")
			{
				alert("请填写具体的配送地址");return false;
			}
        });
    });
    
    </script>
</head>
<body style="BACKGROUND: none;">
	<ul class="top-tool" style="top:0px; left:0px">
		<a href="javascript:history.go(-1)"><span class="back"><img src="./image/back_icon.png"></span></a>
		<span class="title">个人中心</span>
		<a href=""><span class="home"><img src="./image/zy_icon.png"></span></a>
	</ul>
	<div style="height:50px"></div>
	<form name="order" method="post" action="orderstatus.php?act=create">
	<ul class="panel_ul" style="background:#fff;">
<?php 
echo "
		<li class='list_li'><!--<li class='list_li'>-->
			<div class='trade-panel'>
				<a href='javascript:history.go(0)'><img src='".$pro['img']."' width='100%' height='100px'></a>
				<div class='trade-ds'>
					<span class='show_name'>".$pro['name']."</span>
					<span class='show_name' style='color:gray'>颜色分类:".$color.",商品规格:".$size."</span>
					<b>¥&nbsp;".$pro['price']."</b><span style='font-size:0.7rem;color:#F40'>优惠".$red."元</span>
					<input type='hidden' name='price' id='price' value='".$pro['price']."'>
					<input type='hidden' name='color' id='color' value='".$color."'>
					<input type='hidden' name='size' id='size' value='".$size."'>
					<input type='hidden' name='pro_id' id='pro_id' value='".$pro['id']."'>
				</div>
			</div>
		</li>";
?>
	</ul>
	<div class="div-jg">
		<span style="float:left;line-height: 50px">购买数量</span>
		<span style="float:right;line-height: 50px"><input type="number" name="quantity" id="number" value="1"></span>
	</div>
	<div class="div-jg">
		<span style="line-height: 50px">商品优惠：
		<?if ($credit)
		{
			echo '红包抵现 省<input type="button" name="amount" id="red" value="'.$red.'" >元';
		}
		else 
		{
			echo '无';
		}
		?>
		</span>
	</div>
	<div class="div-jg">
		<span style="line-height: 50px">收货人：</span>
		<span><input type="text" name="name" id="name" placeholder="收货人姓名" style="width: 30%;border:none;text-align:right;float:right;height:50px"/></span>
	</div>
	<div class="div-jg">
		<span style="line-height: 50px">联系电话：</span>
		<span><input type="text" name="phone" id="phone" placeholder="请输入手机号码" style="width: 30%;height:50px;border:none;text-align:right;float:right"/></span>
	</div>
	<div style="height:100px;background:#f2f2f3;margin:auto 1%;padding:5px 3%;width:92%;border-radius:10px">
		<img alt="" src="image/qiandao.png" style="float: left;margin: 35px auto;">
		<p style="border:none;text-align:right;float:right;width:80%;">
			<select name="province" id="province" style="width:40%"><option value="">请选择省份</option></select>
			<select name="city" id="city" style="width:40%"><option value="">请选择城市</option></select>
		</p>
		<p><input type="text" name="address" id="address" placeholder="填写收货详细地址" style="width: 70%;height:50px;background:transparent;border:none;border-bottom: 1px solid #ecebf1;text-align:right;float:right"/></p>
	</div>
	<div class="div-jg">
		<span style="line-height: 50px">买家留言：</span>
		<span style=""><input type="text" name="note" placeholder="(选填)对本次交易的说明" style="width: 80%;border:none;height:50px;text-align:right;float:right"/></span>
	</div>
	<div style="height: 50px;width: 100%"></div>
	<div class="bottom_menu">
		<ul>
			<li></li>
			<li style="color:#000;text-align: right;padding-top: 25px;">总计：<input type="button" name="amount" id="totalmoney" value="<?=$price?>" >元&nbsp;</li>
			<li><input type="submit" id="submit" name="submit" value="提交订单" style="background:#F40;color:#fff;width: 100%;height: 100%;font-size: 1rem"></li>
		</ul>
	</div>
	
	</form>
	
	
</body>
</html>